package flc.ast.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.SelectFileBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.utils.MediaUtil;
import stark.common.basic.utils.TimeUtil;

public class VideoRecordAdapter extends StkProviderMultiAdapter<SelectFileBean> {


    public VideoRecordAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new VideoRecordProvider());
    }

    private class VideoRecordProvider extends BaseItemProvider<SelectFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_video_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectFileBean bean) {
            Glide.with(getContext()).load(bean.getPath())
                    .into((ImageView) baseViewHolder.getView(R.id.ivVideoRecordItemImg));
            baseViewHolder.setText(R.id.tvVideoRecordItemDuration, TimeUtil.getMmss(MediaUtil.getDuration(bean.getPath())));
        }
    }

}
